package com.jswdwsx.esign.repo

import com.jswdwsx.esign.cloud.enums.FlowStatusEnum
import com.jswdwsx.esign.entity.FlowPO
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.CrudRepository

interface FlowRepository : CrudRepository<FlowPO, String> {

    fun findByEsignFlowId(esignFlowId: String): FlowPO?

    @Modifying
    @Query("update FlowPO set status = ?3,signUrl = ?4,version = version + 1 where requestId = ?1  AND version=?2")
    fun updateFlow(id: String, version: Int?, status: FlowStatusEnum, signUrl: String?): Int
}